/*
 * EquilibriumConstant.cpp
 *
 *  Created on: 31 Jul 2011
 *      Author: Allan
 */

#include "EquilibriumConstant.h"

// C++ includes
#include <cmath>

EquilibriumConstant::EquilibriumConstant() :
logK(1, 0.0), T(1, 25.0), li(T, logK), knownfunction(false)
{}

EquilibriumConstant::EquilibriumConstant(double logK_) :
logK(1, logK_), T(1, 25.0), li(T, logK), knownfunction(false)
{}

EquilibriumConstant::EquilibriumConstant(double logK_, double T_) :
logK(1, logK_), T(1, T_), li(T, logK), knownfunction(false)
{}

EquilibriumConstant::EquilibriumConstant(const vector<double>& logK_, const vector<double>& T_) :
logK(logK_), T(T_), li(T, logK, 2), knownfunction(false)
{}

EquilibriumConstant::EquilibriumConstant(const Function& K_)
{
	K = K_;
	
	knownfunction = true;
}

void EquilibriumConstant::GetEquilibriumConstantData(vector<double>& logK_, vector<double>& T_) const
{
	logK_ = logK;
	
	T_ = T;
}

const EquilibriumConstant::Function EquilibriumConstant::GetEquilibriumConstantFunction() const
{
	return K;
}

const double EquilibriumConstant::operator()(double T, double P) const
{
	if(knownfunction)
		return K(T, P);
	else
		return std::pow(10.0, li(T));
}
